import Joi from '@hapi/joi';
import { paginateRule } from './common';

export const list = {
  query: {
    name: Joi.string().trim().allow(''),
    url: Joi.string().allow(''),
    uri: Joi.string().allow(''),
    parentId: Joi.string().allow(''),
    ...paginateRule
  },
};

export const create = {
  body: {
    name: Joi.string()
      .trim()
      .required(),
    url: Joi.string()
      .trim()
      .allow(''),
    uri: Joi.string()
      .trim()
      .allow(''),
    isMenu: Joi.number()
      .default(0),
    icon: Joi.string()
      .trim()
      .allow(''),
    describe: Joi.string()
      .trim()
      .allow(''),
    sort: Joi.number().default(0),
    show: Joi.number(),
    parentId: Joi.string()
      .trim()
      .allow(''),
  },
};

export const update = {
  params: {
    id: Joi.string()
      .trim()
      .required(),
  },
  body: create.body,
};

export const destroyRule = {
  params: {
    id: Joi.string()
      .trim()
      .required(),
  },
};
